<template>
  <div class="search">
    <el-card class="box-card" shadow="never">
      <div style="margin-bottom: 5px">
        <el-form :inline="true" label-width="150px"  size="small" @submit.native.prevent>
          <el-form-item label="设备MAC">
            <el-input size="small" v-model="searchKey">
              <el-button slot="append" @click="toggleCollapse" :icon="isCollapse ? 'el-icon-remove-outline':'el-icon-circle-plus-outline'">高级搜索</el-button>
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" size="small" @click="search"><li class="el-icon-search">查询</li></el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-form :model="searchModel" label-width="150px"  size="small" v-bind:style="isCollapse ? 'display:block':'display:none'" @submit.native.prevent>
        <el-form-item label="设备名称">
          <el-input v-model="searchModel.name"></el-input>
        </el-form-item>
        <el-form-item label="设备状态">
          <select class="form-control" v-data-dictionary-directive:B1014 v-model="searchModel.status">
          </select>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'demo-search-bar',
  data () {
    return {
      isCollapse: false,
      searchKey: null,
      searchModel: {
        pageDto: {
          pageSize: 10,
          pageNum: 1,
          pageSizes: [10, 20, 50, 100]
        },
        name: null,
        mac: null,
        status: null
      }
    }
  },
  methods: {
    toggleCollapse: function () {
      this.isCollapse = !this.isCollapse
    },
    search: function () {
      let p = {isCollapse: this.isCollapse, searchKey: this.searchKey, searchModel: this.searchModel}
      this.$emit('search', p)
    }
  }
}
</script>

<style scoped>

</style>
